((document, localStorage, location) => {
    const usernameInput = document.getElementById('username')
    const enterBtn = document.getElementById('enter')

    const init = () => {
        bindEvent()
    }
    function bindEvent(){
        enterBtn.addEventListener('click', handleEnterBtnClick, false)
    }
    function handleEnterBtnClick(){
        const username = usernameInput.value.trim()
        if(username.length < 6){
            alert('用户名不能小于6位')
            return
        }
        localStorage.setItem('username', username)
        location.href = 'index.html'
    }

    init()
})(document, localStorage, location)